home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / mergeini.ps < prev    next >
Text File  |  1994-08-01  |  2KB  |  93 lines

  1. %    Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % mergeini.ps - utility for merging all the Ghostscript initialization files
  20. % (gs_*.ps) into a single file.
  21.  
  22. /rl { in =string readline } def
  23. /wl { out exch writestring out (\n) writestring } def
  24. /infile { findlibfile { exch pop } { (r) file } ifelse } def
  25.  
  26. /merge            % <in_name> <out_name> <squash>
  27.  { /squash exch def
  28.    exch infile
  29.    exch (w) file /out exch def
  30.  
  31.     % Copy comments up to the first blank line,
  32.     % since this is the legal notice for the file.
  33.    /in exch def
  34.     { rl pop dup wl
  35.       () eq { exit } if
  36.     }
  37.    loop
  38.  
  39.    in mergefile
  40.    out closefile
  41.  } def
  42.  
  43. /doit            % <string> -> <string> true | false
  44.  { squash
  45.     { dup () eq
  46.        { pop false
  47.        }
  48.        { dup 0 1 getinterval (%) ne
  49.           { true
  50.       }
  51.       { dup (%END) anchorsearch
  52.          { pop pop true
  53.          }
  54.          { pop pop false
  55.          }
  56.         ifelse
  57.       }
  58.      ifelse
  59.        }
  60.       ifelse
  61.     }
  62.     { true
  63.     }
  64.    ifelse
  65.  } def
  66.  
  67. /mergefile        % <in_file>
  68.  { /in exch def
  69.     { rl not { pop exit } if
  70.       (%% Replace ) anchorsearch
  71.        { pop
  72.          in exch
  73.          token pop            % # of lines
  74.      exch token pop exch pop    % file name or list name
  75.      exch
  76.           { rl pop pop }
  77.      repeat
  78.      exec dup type /stringtype eq { [ exch ] } if
  79.       { infile mergefile
  80.       }
  81.      forall
  82.      /in exch def
  83.        }
  84.        { doit { wl } if
  85.        }
  86.       ifelse
  87.     } loop
  88.    in closefile
  89.  } def
  90.  
  91. (gs_init.ps) (gs_xinit.ps) true merge
  92. quit
  93.